// search界面mock
import Mock from 'mockjs'

// search界面history内容
let { history } = Mock.mock({
    'history|10': [
        {
            id: '@guid',
            text: '@ctitle(1,10)'
        }
    ]
})

// 获取history
Mock.mock('/api/search/history', 'post', () => {
    return {
        code: "200",
        message: '获取search_hisory',
        data: history
    }
})

// 推荐搜索内容
const { recommend_search } = Mock.mock({
    'recommend_search|10': [
        {
            id: '@guid',
            text: '@ctitle(1,10)'
        }
    ]
})

// 获取推荐搜索内容
Mock.mock('/api/home/history/recommend_search', 'post', () => {
    return {
        code: '200',
        message: '获取猜你想搜',
        data: recommend_search
    }
})

// 删除单条搜索记录
Mock.mock('/api/search/delHistory', 'post', (config) => {
    const id = JSON.parse(config.body).id
    history = history.filter(i => {return i.id != id}) 
    
    return {
        code: '200',
        message: '删除搜索记录',
        data: history
    }   
})